<template>
	<view class="coupon">
		<uv-navbar placeholder autoBack bgColor="#CA1C1D">
			<template v-slot:left>
				<view class="left_slot">
					<image src="@/static/images/back.png"></image>
				</view>
			</template>
			<template v-slot:center>
				<view class="nav_title">优惠券</view>
			</template>
		</uv-navbar>
		<view class="header">
			<view class="item" :class="active==1?'active':''" @click="change(1)">待使用(6)</view>
			<view class="item" :class="active==2?'active':''" @click="change(2)">已使用</view>
			<view class="item" :class="active==3?'active':''" @click="change(3)">已过期</view>
		</view>
		<component :is="currentComponent" />
	</view>
</template>

<script setup>
	import ToBeUsed from "@/components/my/ToBeUsed.vue";
	import Used from "@/components/my/Used.vue";
	import Expire from "@/components/my/Expire.vue";
	import {
		ref,
		shallowRef
	} from "vue";
	const currentComponent = shallowRef(Used);
	const active = ref(2);
	const change = (value) => {
		active.value = value;
		if (value == 1) {
			currentComponent.value = ToBeUsed;
		}
		if (value == 2) {
			currentComponent.value = Used;
		}
		if (value == 3) {
			currentComponent.value = Expire;
		}
	};
</script>

<style scoped lang="scss">
	.coupon {
		height: calc(100vh - var(--window-top) - var(--window-bottom));
		box-sizing: border-box;
		background-color: #f5f5f5;
		overflow: hidden;

		.left_slot {
			image {
				width: 43rpx;
				height: 36rpx;
			}
		}

		.nav_title {
			color: #F5F5F5;
			font-size: 36rpx;
		}

		.header {
			width: 100%;
			height: 196rpx;
			padding: 0 60rpx 20rpx;
			box-sizing: border-box;
			background: #CA1C1D;
			display: flex;
			justify-content: space-between;
			align-items: flex-end;

			.item {
				color: #EEEEEE;
				font-size: 30rpx;
				font-weight: bold;

				&.active {
					position: relative;

					&::after {
						content: "";
						width: 76rpx;
						height: 6rpx;
						background: #FFFFFF;
						position: absolute;
						left: 50%;
						bottom: -14rpx;
						transform: translateX(-50%);
						z-index: 2;
					}
				}
			}
		}

		
	}
</style>